﻿using INTEX.DataBase;
using ReflectionStudio.Core.Events;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using WPFExcelReport.ViweModels;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for SETUPABON.xaml
    /// </summary>
    public partial class ITXINTERFACE : UserControl
    {
        ITXINTERFACEViewModel vm;
        public ITXINTERFACE()
        {
            InitializeComponent();
            vm = new ITXINTERFACEViewModel();
            this.DataContext = vm;
        }
        #region=========Property=========
        public static readonly DependencyProperty SetMasterProperty =
DependencyProperty.Register("SetMaster", typeof(SETINTEXDB), typeof(ITXINTERFACE));
        public SETINTEXDB SetMaster
        {
            get
            {
                return this.GetValue(SetMasterProperty) as SETINTEXDB;
            }
            set
            {
                this.SetValue(SetMasterProperty, value);
            }
        }
        public static readonly DependencyProperty SetDetailProperty =
DependencyProperty.Register("SetDetail", typeof(SETINTEXDB), typeof(ITXINTERFACE));
        public SETINTEXDB SetDetail
        {
            get
            {
                return this.GetValue(SetDetailProperty) as SETINTEXDB;
            }
            set
            {
                this.SetValue(SetDetailProperty, value);
            }
        }
        public static readonly DependencyProperty SetEnvProperty =
DependencyProperty.Register("SetEnv", typeof(SETINTEXDB), typeof(ITXINTERFACE));
        public SETINTEXDB SetEnv
        {
            get
            {
                return this.GetValue(SetEnvProperty) as SETINTEXDB;
            }
            set
            {
                this.SetValue(SetEnvProperty, value);
            }
        }


        private Dictionary<string, object> dicParamater
        {
            get
            {
                return vm.dicParamater;
            }
            set
            {
                vm.dicParamater = value;
            }
        }

        public string Mandant
        {
            get
            {
                return vm.Mandant;
            }
        }
        public string company
        {
            get
            {
                return vm.company;
            }
        }
        #endregion
        private void btnGetCADMap_Click(object sender, RoutedEventArgs e)
        {
            DataSet setresult = null;
            try
            {
                SetMaster.Clear();

                setresult = vm.ReSetMaster();
                SetMaster.Merge(setresult);
                SetMaster.AcceptChanges();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {
                SetMaster.Merge(setresult);
                SetMaster.AcceptChanges();
            }
        }
    }
}
